# -*- coding: utf-8 -*-
# @Author: QX
# @File: day5_0051setplace.py
'''
在｛设置｝的App中单击【电池】
'''
from time import sleep

from  appium   import webdriver
from appium.webdriver.common.appiumby import AppiumBy

dic = {
  "platformName": "Android",
  "appium:platformVersion": "9",
  "appium:appPackage": "com.android.settings",
  "appium:appActivity": ".Settings",
  "appium:deviceName": "emulator-5554",
  "appium:automationName": "UIAutomator2"
}
driver = webdriver.Remote('http://127.0.0.1:4723',dic)
sleep(1)
# #单击电池
# eles = driver.find_elements(AppiumBy.ID,'android:id/title')
# eles[3].click()
# sleep(2)
# #单击回退
# driver.find_element(AppiumBy.ACCESSIBILITY_ID,'向上导航').click()
# sleep(2)
# #单击
# eles = driver.find_elements(AppiumBy.CLASS_NAME,'android.widget.TextView')
# eles[4].click()
#
# #回到首页
# driver.find_element(AppiumBy.XPATH,'//android.widget.ImageButton[@content-desc="向上导航"]').click()
#==========================================================
# sleep(2)
#单击搜索按钮
# ele = driver.find_element(AppiumBy.XPATH,'//android.widget.TextView[@resource-id="com.android.settings:id/search_action_bar_title"]')
# ele.click()
# sleep(2)
# #输入搜索内容
# driver.find_element(AppiumBy.ID,'android:id/search_src_text').send_keys('大家好')
#========================================
driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,'new UiSelector().text("显示")').click()
driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,'new UiSelector().className("android.widget.ImageButton")').click()